package models

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
)

//查询数据，指定字段名
func StructQueryField(uid int) (user User) {

	row := MysqlDb.QueryRow("select id, name, age from users where id=?",uid)
	if err :=row.Scan(&user.Id,&user.Name,&user.Age); err != nil{
		fmt.Printf("scan failed, err:%v",err)
		return
	}
	return user
}